//1. CREATE PROJECT - FILE=> NEW=> JAVA PROJECT
//2. IMPORT JAR FILES - RIGHT CLICK ON PROJECT=>PROPERTIES=>JAVA BUILD PATH=>ADD EXTERNAL JARS=> 
// IMPORT SELENIUM JAR FILES AND LIBS
//3. CREATE CLASS- RIGHT CLICK ON SRC=>NEW=>CLASS 

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class firstProgram {
	public static void main(String[] args) {		
		
		//CREATE OBJECT FIRST//		
		WebDriver driver = new FirefoxDriver ();
		
		//OPEN THE URL//
		driver.get("http://facebook.com");
		
		//PRINT TITLE OF THE PAGE//                   //SYSO+CNTRL+SPACE  FOR SYSTEM.OUT.PRINTLN //
		System.out.println(driver.getTitle());
		
		//PRINT URL OF THE PAGE//
		System.out.println(driver.getCurrentUrl());
		
		//FIND ELEMENTS ON THE PAGE//              / /DOWNLOAD FIREBUG AND FIREPATH TO IDENTIFY ELEMENTS// 
		
		//OBJECTS CAN BE IDENTIFIED IN AN ELEMENT USING XPATH, ID, NAME, LINKTEXT, CLASSNAME,PARTIALLINK
		//AND TAGNAME.  WE USE XPATH MOST OF THE TIME (99%).  BUT USE OTHER PROPERTIES WHEN DYNAMIC //
		
		//COMMAND FOR ENTERING LOGIN ID IN LOGIN FIELD BY USING ELEMENTS AND SENDKEYS //
		driver.findElement(By.xpath(".//*[@id='email']")).sendKeys("sarabjit115@yahoo.com");
		
		//COMMAND FOR ENTERING PASSWORD IN PASSWORD FIELD BY USING ELEMENTS AND SENDKEYS //
		driver.findElement(By.id("pass")).sendKeys("kushpreet");
		
		//COMMAND FOR CLICKING LOGIN BUTTON
		driver.findElement(By.xpath(".//*[@id='u_0_n']")).click();
		
		//COMMAND FOR CLICKING DROPDOWN BUTTON FOR LOGIN OUT BY USING XPATH ELEMENT		
		driver.findElement(By.xpath(".//*[@id='pageLoginAnchor']")).click();
		
		//COMMAND FOR CLICKING LOGIN OUT BUTTON BY USING XPATH BUTTON
		driver.findElement(By.xpath(".//*[@id='logout_form']/label/input")).click();
		
		//COMMAND FOR CLOSING THE BROWSER WINDOW
		driver.close();
		
		
		
		

	}

}
